﻿Imports CustomTshirtFinal
Public Class Productos

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim form As New ProductoNuevo
        form.MdiParent = Me.MdiParent
        form.Productos = Me
        form.Show()
    End Sub


    Private Sub btnBuscar_Click(sender As System.Object, e As System.EventArgs) Handles btnBuscar.Click
        Dim criterio As String = Me.txtBuscar.Text

        Dim negocio As New ProductoNegocio
        Dim producto As Collection = negocio.buscarPorNombre(criterio)
        Me.dgvProductos.DataSource = producto
        Me.dgvProductos.EditMode = False

        Me.dgvProductos.Columns(0).HeaderText = "Id Producto"
        Me.dgvProductos.Columns(1).HeaderText = "Nombre"
        Me.dgvProductos.Columns(2).HeaderText = "Descripción"
        Me.dgvProductos.Columns(3).HeaderText = "Precio"
        Me.dgvProductos.Columns(4).HeaderText = "Stock"
        Me.dgvProductos.Columns(5).HeaderText = "Importancia"
    End Sub

    Private Sub Productos_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        With Me.dgvProductos.ColumnHeadersDefaultCellStyle
            .BackColor = Color.Green
            .ForeColor = Color.DarkGreen

        End With
    End Sub

    
    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Dim selecionado = Me.dgvProductos.CurrentRow.Cells(0).Value.ToString

        Dim form As New ProductoNuevo
        form.MdiParent = Me.MdiParent
        form.lblId.Text = selecionado
        form.Productos = Me
        form.Show()
    End Sub

    Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
        Dim seleccionado = Me.dgvProductos.CurrentRow.Cells(0).Value.ToString
        Dim negocio As New ProductoNegocio
        negocio.eliminar(seleccionado)
        dgvProductos.DataSource = ""


    End Sub
End Class